home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 788 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. Path: mxsld2.pd.infn.it!LORETI
  3. From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
  4. Subject: Re: start array at k, not 0
  5. X-Nntp-Posting-Host: mxsld2.pd.infn.it
  6. Message-ID: <DKwoyx.MD@news.cern.ch>
  7. Sender: news@news.cern.ch (USENET News System)
  8. Reply-To: loreti@mxsld2.pd.infn.it
  9. Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
  10. References: <Pine.OSF.3.91.960104095358.22268B-100000@io.UWinnipeg.ca> <820787486snz@genesis.demon.co.uk> <Pine.OSF.3.91.960105091211.2861B-100000@io.UWinnipeg.ca> <4cpdt3$3b5@newdelph.cig.mot.com> <30f06d21.167303296@nntp.ix.netcom.com>,<tbutler.821142000@laraby.tiac.net>
  11. Date: Tue, 9 Jan 1996 08:58:56 GMT
  12.  
  13. In article <tbutler.821142000@laraby.tiac.net>, tbutler@laraby.tiac.net (Tim Butler) writes:
  14. >miker3@ix.netcom.com (Mike Rubenstein) writes:
  15. >[ Numerical Recipes method of array indexing referenced ]
  16. >.....
  17. >:It's unfortunate that the authors of this book didn't bother to learn
  18. >:C before writing it.  As anyone who has read the FAQ [6.13] knows,
  19. >:this results in undefined behavior.  
  20. >....
  21. >
  22. >They have addressed that in the second edition. To retain the ability
  23. >to start indexing at one, they "waste" that first element. They
  24. >allocate one element extra.
  25. >
  26. >--
  27. >tim butler
  28. >tbutler@tiac.net
  29.  
  30. Sorry, wrong.  From the second edition, 1992 (ISBN 0-521-43108-5),
  31. page 19 (emphasis on PERVERSELY mine):
  32.  
  33. "But suppose that your vector of length 7, now call it a ... is
  34. PERVERSELY a native C, zero-offset array. ... Heaven help you! ... You
  35. simply invoke someroutine(a-1,7) ... We want to free you from the
  36. zero-offset thinking that C encourages ... A final liberating-point is
  37. that the utility file nrutil.c, listed in full in Appendix B, includes
  38. functions for allocating arbitrary-offset vectors of arbitrary
  39. lengths."
  40.  
  41. Of course, nrutil.c in Appendix B uses the same WRONG trick.  Please,
  42. realize that Press, Teukolsky, Vetterling and Flannery MAY know
  43. algorithms (some disagree on that too; see
  44. http://www.lysator.liu.se/c/num-recipes-in-c.html) but FOR SURE they
  45. do NOT know C.
  46. --
  47. Maurizio Loreti                       http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
  48. Un. of Padova, Dept. of Physics - Padova, Italy          loreti@padova.infn.it
  49.